package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.app.hfinterface.SecondHandItemClickCall;
import com.kmproject.haifu.mvp.model.entity.beans.SecondHandTreeTypeBean;

import java.util.List;

public class SecondhandPublicshSelectTypeAdapter extends BaseQuickAdapter<SecondHandTreeTypeBean, BaseViewHolder> {
    int selectSexIndex=0;
    SecondHandItemClickCall mSecondHandItemClickCall;
    public SecondhandPublicshSelectTypeAdapter(@Nullable List<SecondHandTreeTypeBean> data,SecondHandItemClickCall secondHandItemClickCall) {
        super(R.layout.secondhand_publicsh_selecttype_item, data);
        mSecondHandItemClickCall=secondHandItemClickCall;
    }

    @Override
    protected void convert(BaseViewHolder helper, SecondHandTreeTypeBean item) {
      helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_txt).setText(item.getName());
      helper.itemView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              selectSexIndex=helper.getPosition();
             notifyDataSetChanged();
          }
      });
      if (selectSexIndex==helper.getPosition())
      {
          helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_txt).setBackgroundColor(ArmsUtils.getColor(mContext,R.color.white));
          helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
          mSecondHandItemClickCall.call(item);
      }else {
          helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_txt).setBackgroundColor(ArmsUtils.getColor(mContext,R.color.color_EDEDED));
          helper.<TextView>getView(R.id.secondhand_publicsh_selecttype_item_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_747474));
      }
    }


}
